package login;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.*;
	  
	   class MioLogin1 extends JFrame implements ActionListener {
		   ActionListener listener;
		   ImagePanell panel = new ImagePanell(new ImageIcon("C:\\Users\\acer\\workspace1\\EsameLDAlgoritmi\\src\\Images\\image-1.jpg").getImage());
			
	 
			 private  JButton entra=new JButton("Entra");
			    final JTextField user_tf = new JTextField();
			    final  JPasswordField pass_tf = new JPasswordField();
			    JDialog frame;
			    private String usr = "user";
			    private String psw = "password";

			public MioLogin1(){
				 frame = new JDialog();
			        frame.setModal(true);
			       
			        frame.setTitle("LOGIN");
					 frame.setSize(500,300);
					 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
					 frame.setLocation(350, 150);
				        
					
		        // pannello
		        panel.setSize(new Dimension(700,400));
		        panel.setMaximumSize(new Dimension(700,400));
		        panel.setMinimumSize(new Dimension(700,400));
		        panel.setPreferredSize(new Dimension(700,400));
		        panel.setLayout(null);
		 
		        // JLabel
		        JLabel user = new JLabel("Username");
		        JLabel password = new JLabel("Password");
		        
		        
		 
		        // entra button
		        entra.setBounds(510,265,120, 65);
		        entra.setBorder(null);
		        entra.addActionListener(listener);
		        entra.setFont(new Font("Impact",Font.TRUETYPE_FONT,16));
		        entra.setForeground(new java.awt.Color(64,0,64));
		        //user,password label
		        user.setBounds(30,60, 260,80);
		        password.setBounds(30, 160, 260, 80);
		        user.setForeground(new java.awt.Color(0,0,0));
		       password.setForeground(new java.awt.Color(0,0,0));
		 
		        // campi di inserimento
		        user_tf.setBounds(100, 80, 190, 40);
		        pass_tf.setBounds(100, 180, 190, 40);
		 
		        // aggiungo al panello principale
		      
		        panel.add(user);
		        panel.add(password);
		        panel.add(user_tf);
		        panel.add(pass_tf);
		        panel.add(entra);
		        
		        frame.add(panel);
		        frame.setResizable(false);
		        frame.pack();
		        frame.setVisible(true);
			}

	     public static void main(String[] args) {
		       
		    MioLogin1 f = new MioLogin1();
		       f.setTitle("LOGIN");
		       
		        
		        
		       
		 }

		@Override
		
			public void actionPerformed(ActionEvent ae) {
				
				//rivedere
				if( ae.getSource()==entra){
				
					SwingUtilities.invokeLater(new Runnable() {
						public void run() {
							PagPers ins = new PagPers();
							ins.setLocationRelativeTo(null);
							ins.setVisible(true);
					
				        }
					});
				}
					frame.dispose();  }
			
		

	  
  }



